FROM maven:3-jdk-8-alpine
WORKDIR /app
COPY pom.xml ./pom.xml
RUN mvn package -P docker-local -Dmaven.test.skip=true

FROM maven:3-jdk-8-alpine
WORKDIR /app
COPY src ./src
COPY --from=0 /app/pom.xml ./pom.xml
COPY --from=0 /root/.m2 /root/.m2
RUN mvn package -P docker-local -Dmaven.test.skip=true

FROM openjdk:8-jre-alpine
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN apk add tzdata
WORKDIR /app
COPY --from=1 /app/target/app.jar ./app.jar
ENV TZ=PRC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ENTRYPOINT ["java","-jar","-Dspring.profiles.active=docker","/app/app.jar"]
